import uliweb
from uliweb.orm import get_model

Kfzx = get_model('kfzx')

r = uliweb.settings.get_var('PARA/KFZX', [])
for id, name, type in r:
    obj = Kfzx.get(id)
    if not obj:
        obj = Kfzx(id=id, name=name, type=type).save(insert=True)
    else:
        obj.update(name=name, type=type).save()

Tx = get_model('tx')

r = uliweb.settings.get_var('PARA/TX', [])
for id, name in r:
    obj = Tx.get(id)
    if not obj:
        obj = Tx(id=id, name=name).save(insert=True)
    else:
        obj.update(name=name).save()


